// 引入组件及类型
import type { App, Component } from "vue";
import * as icons from "@element-plus/icons-vue";
import SvgIcon from "./svgIcon/index.vue";

// 定义全局对象接口;
interface IComponents {
  [name: string]: Component;
}

// 全局对象
const Components: IComponents = {
  SvgIcon,
};

/** 用于注册components文件夹内部全部全局组件 */
export default {
  // 定义install方法
  install: (app: App) => {
    // 遍历对象
    Object.keys(Components).forEach(key => {
      // 注册全局组件
      app.component(key, Components[key]);
    });
    //所有ElementPlus图标并进行全局注册;
    for (const [key, component] of Object.entries(icons)) {
      app.component(key, component);
    }
  },
};
